<?php
/**
 * @copyright   Copyright (C) Open Web Software Ltda. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/* The following line loads the MooTools JavaScript Library */
JHtml::_('behavior.framework', false);

/* The following line gets the application object for things like displaying the site name */
$app        = JFactory::getApplication();
$doc        = JFactory::getDocument();

$jqueryV    = "1.10.2";
$bootstrapV = "3.0.3";
$lessV      = "1.5.0";

/* get params */
$templateparams   = $app->getTemplate(true)->params;

include (dirname(__FILE__).DS.'/tools/tools.php');

if(( $detect->isMobile() && $mobileTemplate) || (isset($_GET['mobile']) && $_GET['mobile'] == "ok" && $mobileTemplate) ){
  include (dirname(__FILE__).DS.'index.mobile.php');
}else{
  $doc->addStyleSheet($this->baseurl . 'templates/'.$this->template.'/bootstrap/'.$bootstrapV.'/css/bootstrap.css', $type = 'text/css');
  //$doc->addStyleSheet($this->baseurl . 'templates/'.$this->template.'/css/template.css', $type = 'text/css'); 
  if(file_exists($_SERVER['DOCUMENT_ROOT'] . $cssBrowser)){
    $doc->addStyleSheet($cssBrowser, $type = 'text/css', $media = 'screen,projection');
  }
  $doc->addScript($this->baseurl . 'templates/'.$this->template.'/js/jquery/jquery-'.$jqueryV.'.min.js', 'text/javascript');
  $doc->addScript($this->baseurl . 'templates/'.$this->template.'/js/jquery/jquery-noconflict.js', 'text/javascript');
  $doc->addScript($this->baseurl . 'templates/'.$this->template.'/bootstrap/'.$bootstrapV.'/js/bootstrap.min.js', 'text/javascript');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <jdoc:include type="head" />
  <link rel="stylesheet" href="<?php echo $this->baseurl.'templates/'.$this->template.'/css/template.less' ?>" type="text/less" />
  <!-- Eliminar el siguiente script de less en produccion -->
  <script type="text/javascript">
  less = {
    env: "development", // or "production"
    async: false,       // load imports async
    fileAsync: false,   // load imports async when in a page under
                        // a file protocol
    poll: 1000,         // when in watch mode, time in ms between polls
    //functions: {},      // user functions, keyed by name
    //dumpLineNumbers: "comments", // or "mediaQuery" or "all"
    //relativeUrls: false,// whether to adjust url's to be relative
                         // if false, url's are already relative to the
                         // entry less file
    //rootpath: ":/a.com/"// a path to add on to the start of every url
                          //resource
  };
  </script>
  <script src="<?php echo $this->baseurl . 'templates/'.$this->template.'/js/less/less-'.$lessV.'.min.js';?>" type="text/javascript"></script>
  <?php if($googleAnalitycs != ""){ ?>
  <script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '<?php echo $googleAnalitycs; ?>']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  </script>
  <?php } ?>
</head>
<body>
  <div class="accessibility">
    <ul>
      <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_NAV'); ?></a></li>
      <?php if ($this->countModules( 'nav2' )) : ?>
      <li><a href="#aside"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_NAV2'); ?></a></li>
      <?php endif; ?>
      <li><a href="#content"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_CONTENT'); ?></a></li>
      <li><a href="#footer"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_FOOTER'); ?></a></li>
    </ul>
  </div>
  <?php if ($this->countModules('usermenu')) : ?>
  <div id="usermenu">
    <div class="container">
      <div class="nav">
        <jdoc:include type="modules" name="usermenu" style="none" />
      </div>
    </div>
  </div>
  <?php endif; ?>
  <?php if(!$editMode){ ?>
  <header>
    <div class="container">
      <?php if ($this->countModules('logo')) : ?>
      <div id="logo"><jdoc:include type="modules" name="logo" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('tagline')) : ?>
      <div id="tagline"><jdoc:include type="modules" name="tagline" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('nav01')) : ?>
      <div id="nav01"><jdoc:include type="modules" name="nav01" style="nav" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('search')) : ?>
      <div id="search"><jdoc:include type="modules" name="search" style="none" /></div>
      <?php endif; ?>
      <?php if ($this->countModules('account')) : ?>
      <div id="account"><jdoc:include type="modules" name="account" style="none" /></div>
      <?php endif; ?>
    </div>
  </header>
  <?php if (!$editMode && $this->countModules( 'breadcrumbs' )) : ?>
  <div id="breadcrumbs">
    <div class="container">
      <jdoc:include type="modules" name="breadcrumbs" style="none" />
    </div>
  </div>
  <?php endif; ?>
  <?php } ?>
  <?php if (
    !$editMode && (
    $this->countModules('featured1A') ||
    $this->countModules('featured1B') ||
    $this->countModules('featured1C') ||
    $this->countModules('featured2A') ||
    $this->countModules('featured2B') ||
    $this->countModules('featured2C') ||
    $this->countModules('featured3A') ||
    $this->countModules('featured3B') ||
    $this->countModules('featured3C')
    )) {
  ?>
  <div id="featured">
    <div class="container">
      <?php if ( $this->countModules('featured1A') || $this->countModules('featured1B') || $this->countModules('featured1C') ) { ?>
      <div id="featured1" class="row">
        <?php if ($this->countModules('featured1A')) : ?>
        <div id="featured1A" class="<?php echo $featured1A ?>">
          <jdoc:include type="modules" name="featured1A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured1B')) : ?>
        <div id="featured1B" class="<?php echo $featured1B ?>">
          <jdoc:include type="modules" name="featured1B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured1C')) : ?>
        <div id="featured1C" class="<?php echo $featured1C ?>">
          <jdoc:include type="modules" name="featured1C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
      </div>
      <?php } ?>
      <?php if ( $this->countModules('featured2A') || $this->countModules('featured2B') || $this->countModules('featured2C') ) { ?>
      <div id="featured2" class="row">
        <?php if ($this->countModules('featured2A')) : ?>
        <div id="featured2A" class="<?php echo $featured2A ?>">
          <jdoc:include type="modules" name="featured2A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured2B')) : ?>
        <div id="featured2B" class="<?php echo $featured2B ?>">
          <jdoc:include type="modules" name="featured2B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured2C')) : ?>
        <div id="featured2C" class="<?php echo $featured2C ?>">
          <jdoc:include type="modules" name="featured2C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
      </div>
      <?php } ?>
      <?php if ( $this->countModules('featured3A') || $this->countModules('featured3B') || $this->countModules('featured3C') ) { ?>
      <div id="featured3" class="row">
        <?php if ($this->countModules('featured3A')) : ?>
        <div id="featured3A" class="<?php echo $featured3A ?>">
          <jdoc:include type="modules" name="featured3A" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured3B')) : ?>
        <div id="featured3B" class="<?php echo $featured3B ?>">
          <jdoc:include type="modules" name="featured3B" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
        <?php if ($this->countModules('featured3C')) : ?>
        <div id="featured3C" class="<?php echo $featured3C ?>">
          <jdoc:include type="modules" name="featured3C" style="xhtml2" headerLevel="5" />
        </div>
        <?php endif; ?>
      </div>
      <?php } ?>
    </div>
  </div>
  <?php } ?>
  <div id="main">
    <div class="container">
      <div class="row">
        <?php if (!$editMode && ($this->countModules( 'col1Top' ) || $this->countModules( 'nav02' ) || $this->countModules( 'col1Bottom' ))) : ?>
        <div id="col1" class="col-md-3">
          <div class="aside">
            <?php if ($this->countModules( 'col1Top' )) : ?>
            <jdoc:include type="modules" name="col1Top" style="xhtml1" />
            <?php endif; ?>
            <?php if ($this->countModules( 'nav02' )) : ?>
            <div class="nav"><jdoc:include type="modules" name="nav02" style="xhtml1" /></div>
            <?php endif; ?>
            <?php if ($this->countModules( 'col1Bottom' )) : ?>
            <jdoc:include type="modules" name="col1Bottom" style="xhtml1" />
            <?php endif; ?>
          </div>
        </div>
        <?php endif; ?>
        <div id="content" class="<?php echo $contentSpan ?>">
          <div class="padding">
            <?php if (!$editMode && $this->countModules( 'nav03' )) : ?>
            <div class="nav"><jdoc:include type="modules" name="nav03" style="none" /></div>
            <?php endif; ?>
            <?php if (!$editMode && $this->countModules( 'top' )) : ?>
            <div class="top"><jdoc:include type="modules" name="top" style="xhtml1" /></div>
            <?php endif; ?>
            <div id="message"><jdoc:include type="message" /></div>
            <div id="component"><jdoc:include type="component" /></div>
            <div class="accessibility">
              <ul>
                <li><a href="#header"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_TOP'); ?></a></li>
                <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_NAV'); ?></a></li>
              </ul>
            </div>
            <?php if (!$editMode && $this->countModules( 'extras' )) : ?>
            <div id="extras"><jdoc:include type="modules" name="extras" style="xhtml1" headerLevel="4" /></div>
            <?php endif; ?>
          </div>
        </div>
        <?php if (!$editMode && ($this->countModules( 'col2Top' ) || $this->countModules( 'nav04' ) || $this->countModules( 'col2Bottom' ))) : ?>
        <div id="col2" class="col-md-3">
          <div class="aside">
            <div class="padding">
              <?php if ($this->countModules( 'col2Top' )) : ?>
              <jdoc:include type="modules" name="col2Top" style="xhtml1" />
              <?php endif; ?>
              <?php if ($this->countModules( 'nav04' )) : ?>
              <div class="nav"><jdoc:include type="modules" name="nav04" style="xhtml1" /></div>
              <?php endif; ?>
              <?php if ($this->countModules( 'col2Bottom' )) : ?>
              <jdoc:include type="modules" name="col2Bottom" style="xhtml1" />
              <?php endif; ?>
            </div>
          </div>
        </div>
        <?php endif; ?>
      </div>
    </div>
  </div>
  <?php if (!$editMode && $this->countModules( 'bottom' )) {
    $spanBS = 12/$this->countModules( 'bottom' )
  ?>
  <div id="bottom">
    <div class="container">
      <div class="row">
        <jdoc:include type="modules" name="bottom" headerLevel="2" style="rowBS" spanBS="<?php echo $spanBS; ?>" />
      </div>
    </div>
  </div>
  <?php } ?>
  <?php if(!$editMode){ ?>
  <div id="footer">
    <div id="footerT">
      <div class="container">
        <div class="row">
          <div id="footer1" class="col-md-3"><jdoc:include type="modules" name="footer1" style="xhtml1" headerLevel="4" /></div>
          <div id="footer2" class="col-md-3"><jdoc:include type="modules" name="footer2" style="xhtml1" headerLevel="4" /></div>
          <div id="footer3" class="col-md-3"><jdoc:include type="modules" name="footer3" style="xhtml1" headerLevel="4" /></div>
          <div id="footer4" class="col-md-3"><jdoc:include type="modules" name="footer4" style="xhtml1" headerLevel="4" /></div>
        </div>
        <div id="footer5"><jdoc:include type="modules" name="footer5" style="xhtml1" headerLevel="4" /></div>
      </div>
    </div>
    <div id="footerB">
      <div class="container">
        <div class="row">
          <div id="footer6" class="col-md-6"><jdoc:include type="modules" name="footer6" style="xhtml1" headerLevel="4" /></div>
          <div id="footer7" class="col-md-6"><jdoc:include type="modules" name="footer7" style="xhtml1" headerLevel="4" /></div>
        </div>
      </div>
    </div>
  </div>
  <?php } ?>
  <div class="accessibility">
    <ul>
      <li><a href="#mainmenu"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_NAV'); ?></a></li>
      <li><a href="#content"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_CONTENT'); ?></a></li>
      <li><a href="#header"><?php echo JText::_('TPL_OW-VISION_JUMP_TO_TOP'); ?></a></li>
    </ul>
  </div>
  <?php
  if($debugMode){
    include (dirname(__FILE__).DS.'/tools/debug.php');
  } ?>
</body>
</html>
<?php } ?>